﻿/*------------------------------------------------
 Author:ShenDuo
 CreatedDate:2019.3.19
 UpdatedDate:
 version:0.1
 ------------------------------------------------*/

using System;
using TrainsTraining.Enum;

namespace TrainsTraining
{
    /// <summary>
    ///     Entry class of trains training
    /// </summary>
    internal class Program
    {
        private static void Main(string[] args)
        {
            //routes tips
            TipsInputMGraph();

            //set matrix graph
            MGraphHelper.SetMGraph();

            //unended program
            while (true)
                //choose a action
                ChooseAction();
        }

        /// <summary>
        ///     Choose a action
        /// </summary>
        private static void ChooseAction()
        {
            //display input tips
            TipsChooseAction();

            //action index
            int actionIndex = Convert.ToInt32(Console.ReadLine());

            //result
            dynamic result = null;

            switch (actionIndex)
            {
                //fixed path distance
                case (int)ActionEnum.FixedRouteDistance:
                    Console.WriteLine("---->Calculate the fixed path distance.(ex: ABC):");
                    result = Trains.GetFixedPathDistance(Console.ReadLine());
                    break;

                //The length of the shortest route
                case (int)ActionEnum.ShortestRoute:
                    Console.WriteLine(
                        "---->The length of the shortest route (in terms of distance to travel)(ex: AC/BB):");
                    result = Trains.GetMinDistance(Console.ReadLine());
                    break;

                //The number of trips at starting point and ending point with a maximum of N stops
                case (int)ActionEnum.TripsNumberForMaxStops:
                    Console.WriteLine(
                        "---->The number of trips at starting point and ending point with a maximum of N stops(ex: CC3):");
                    result = Trains.GetMaxTripsNumber(Console.ReadLine());
                    break;

                //The number of trips at starting point and ending point with exactly N stops
                case (int)ActionEnum.TripsNumberForExactlyStops:
                    Console.WriteLine(
                        "---->The number of trips at starting point and ending point with exactly N stops(ex: AC4):");
                    result = Trains.GetEqualTripsNumber(Console.ReadLine());
                    break;

                //The number of different routes from starting point to ending point with a distance of less than N
                case (int)ActionEnum.TripsNumberForLessThan30Distance:
                    Console.WriteLine(
                        "---->The number of different routes from starting point to ending point with a distance of less than N.(ex: CC30):");
                    result = Trains.GetLessThanDistanceTripsNumber(Console.ReadLine());
                    break;

                //Reset the initial routing graph
                case (int)ActionEnum.ResetInitRoutes:
                    TipsInputMGraph();
                    break;
            }

            //show result
            if (result != null)
                Console.WriteLine(result);
        }

        /// <summary>
        ///     Tips infos for action
        /// </summary>
        private static void TipsChooseAction()
        {
            Console.WriteLine("Please choose a action(1-5).");
            Console.WriteLine("[1]Calculate the fixed path distance.(ex: ABC).");
            Console.WriteLine(
                "[2]The number of trips at starting point and ending point with a maximum of N stops(ex: CC3).");
            Console.WriteLine(
                "[3]The number of trips at starting point and ending point with exactly N stops(ex: AC4).");
            Console.WriteLine("[4]The length of the shortest route (in terms of distance to travel)(ex: AC/BB).");
            Console.WriteLine(
                "[5]The number of different routes from starting point to ending point with a distance of less than N.(ex: CC30).");
            Console.WriteLine(
                "[6]Reset the initial routing graph.");
        }

        /// <summary>
        ///     Tips infos for init routes
        /// </summary>
        private static void TipsInputMGraph()
        {
            Console.WriteLine("---->Please input routes for matrix graph(ex: AB5,BC4,CD8,DC8,DE6,AD5,CE2,EB3,AE7):");
        }
    }
}